<?php
include_once '../classes/dao.php';
include_once '../classes/sugestoes.php';

$dao = new DAO();

if (!isset($_REQUEST["term"])) {
	exit;
}

$consulta = $_REQUEST["term"];

$tipos = $dao->consulta_tipos_links($consulta);

$sugestoes = new Sugestoes();
foreach ($tipos as $indice => $tipo) {
	$sugestoes->adicionar_sugestao($indice, $tipo);
}

echo $sugestoes->get_json();
?>